﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class MasterPage : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["Logined"] != null)
        {
            if((bool)Session["Logined"] == true)
            {
                hpLogin.Visible = false;
                hpRegister.Visible = false;
                hpLogout.Visible = true;
                welcome.Visible = true;
                linkUserProfile.Text = (String)Session["Username"];
            }
            else
            {
                welcome.Visible = false;
                hpLogin.Visible = true;
                hpRegister.Visible = true;
                hpLogout.Visible = false;
            }

            int role = Int32.Parse((String)Session["Userrole"]);
            switch (role)
            {
                case Global.ADMIN_ROLE:
                    guestMenu.Visible = false;
                    adminMenu.Visible = true;
                    studentMenu.Visible = false;
                    teacherMenu.Visible = false;
                    break;
                case Global.STUDENT_ROLE:
                    guestMenu.Visible = false;
                    adminMenu.Visible = false;
                    studentMenu.Visible = true;
                    teacherMenu.Visible = false;
                    break;
                case Global.TEACHER_ROLE:
                    guestMenu.Visible = false;
                    adminMenu.Visible = false;
                    studentMenu.Visible = false;
                    teacherMenu.Visible = true;
                    break;
            }
        }
        else
        {
            guestMenu.Visible = true;
            adminMenu.Visible = false;
            studentMenu.Visible = false;
            teacherMenu.Visible = false;
            welcome.Visible = false;
            hpLogin.Visible = true;
            hpRegister.Visible = true;
            hpLogout.Visible = false;
        }
    }
}
